/**
 *
 */
package idao;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.sql.ResultSet;

/**
 * Indicates the annotated methods are used to select data from database.
 * 
 * @author huhao
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Query
{

    /** SQL statement. */
    String value();

    // member annotations

    /**
     * Specify the {@link idao.RowHandler} used to extract data from {@link ResultSet} row
     * by row. Will be ignored if a {@link idao.ResultSetHandler} is specified.
     */
    public @interface RowHandler
    {
        Class<? extends idao.RowHandler> value();

        String[] initParameters() default {};
    }

    /**
     * Specify the {@link idao.ResultSetHandler} used to extract data from
     * {@link ResultSet}.
     */
    public @interface ResultSetHandler
    {
        Class<? extends idao.ResultSetHandler> value();

        String[] initParameters() default {};
    }

    /**
     * Specify element type of the collection.<br>
     * Mandatory when the dao method has a return type of
     * <ul>
     * <li>java.util.Collection</li>
     * <li>java.util.List</li>
     * <li>java.util.Set</li>
     * </ul>
     * unless a {@link ResultSetHandler} or {@link RowHandler} is specified.
     */
    /*
     * public @interface CollectionElementType { Class<?> value(); }
     */
}
